home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / RWbistream.z / RWbistream
Encoding:
Text File  |  1998-10-30  |  19.4 KB  |  397 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWbistream - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <rw/bstream.h>
  13.  
  14.  
  15.  
  16.               RWbistream bstr(cin);        // Construct an RWbistream,
  17.                                        // using cin's streambuf
  18.  
  19.  
  20.  
  21.  
  22. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  23.      Class RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm specializes the abstract base class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm to
  24.      restore variables stored in binary format by RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm.  You can think
  25.      of it as a binary veneer over an associated ssssttttrrrreeeeaaaammmmbbbbuuuuffff.  Because the
  26.      RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm retains no information about the state of its associated
  27.      ssssttttrrrreeeeaaaammmmbbbbuuuuffff, its use can be freely exchanged with other users of the
  28.      ssssttttrrrreeeeaaaammmmbbbbuuuuffff (such as an iiiissssttttrrrreeeeaaaammmm or iiiiffffssssttttrrrreeeeaaaammmm).  RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm can be
  29.      interrogated as to the stream state using member functions ggggoooooooodddd(((()))), bbbbaaaadddd(((()))),
  30.      eeeeooooffff(((()))), eeeettttcccc.
  31.  
  32. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  33.      None
  34.  
  35. EEEExxxxaaaammmmpppplllleeee
  36.      See RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm for an example of how the file "ddddaaaattttaaaa....ddddaaaatttt" might be
  37.      created.
  38.  
  39.               #include <rw/bstream.h>
  40.           #include <fstream.h>
  41.           main(){
  42.             ifstream fstr("data.dat");    // Open an input file
  43.             RWbistream bstr(fstr);     // Construct RWbistream from it
  44.             int i;
  45.             float f;
  46.             double d;
  47.             bstr >> i;         // Restore an int that was stored in binary
  48.             bstr >> f >> d;    // Restore a float & double
  49.           }
  50.  
  51.  
  52. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  53.               RWbistream(streambuf* s);
  54.  
  55.  
  56.      Construct an RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm from the ssssttttrrrreeeeaaaammmmbbbbuuuuffff ssss.  For DOS, this ssssttttrrrreeeeaaaammmmbbbbuuuuffff
  57.      must have been opened in binary mode.
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.               RWbistream(istream& str);
  75.  
  76.  
  77.      Construct an RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm using the ssssttttrrrreeeeaaaammmmbbbbuuuuffff associated with the iiiissssttttrrrreeeeaaaammmm
  78.      ssssttttrrrr.  For DOS, the ssssttttrrrreeeeaaaammmmbbbbuuuuffff must have been opened in binary mode.  This
  79.      can be done by specifying iiiioooossss::::::::bbbbiiiinnnnaaaarrrryyyy as part of the second argument to
  80.      the constructor for and iiiiffffssssttttrrrreeeeaaaammmm.  Using the example above, the line to
  81.      create the iiiiffffssssttttrrrreeeeaaaammmm would read, iiiiffffssssttttrrrreeeeaaaammmm ffffssssttttrrrr((((""""ddddaaaattttaaaa....ddddaaaatttt"""",,,, iiiioooossss::::::::iiiinnnn ||||
  82.      iiiioooossss::::::::bbbbiiiinnnnaaaarrrryyyy))));;;; where the "||||" is the binary OR operator.
  83.  
  84. PPPPuuuubbbblllliiiicccc OOOOppppeeeerrrraaaattttoooorrrrssss
  85.               virtual RWvistream&
  86.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(char& c);
  87.  
  88.  
  89.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next cccchhhhaaaarrrr from the input stream
  90.      and store it in cccc.
  91.  
  92.               virtual RWvistream&
  93.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(wchar_t& wc);
  94.  
  95.  
  96.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next wide cccchhhhaaaarrrr from the input
  97.      stream and store it in wwwwcccc.
  98.  
  99.               virtual RWvistream&
  100.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(double& d);
  101.  
  102.  
  103.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next ddddoooouuuubbbblllleeee from the input
  104.      stream and store it in dddd.
  105.  
  106.               virtual RWvistream&
  107.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(float& f);
  108.  
  109.  
  110.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next ffffllllooooaaaatttt from the input
  111.      stream and store it in ffff.
  112.  
  113.               virtual RWvistream&
  114.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(int& i);
  115.  
  116.  
  117.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next iiiinnnntttt from the input stream
  118.      and store it in iiii.
  119.  
  120.               virtual RWvistream&
  121.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(long& l);
  122.  
  123.  
  124.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next lllloooonnnngggg from the input stream
  125.      and store it in llll.
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.               virtual RWvistream&
  141.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(short& s);
  142.  
  143.  
  144.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next sssshhhhoooorrrrtttt from the input
  145.      stream and store it in ssss.
  146.  
  147.               virtual RWvistream&
  148.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(unsigned char& c);
  149.  
  150.  
  151.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next uuuunnnnssssiiiiggggnnnneeeedddd cccchhhhaaaarrrr from the
  152.      input stream and store it in cccc.
  153.  
  154.               virtual RWvistream&
  155.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(unsigned short& s);
  156.  
  157.  
  158.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next uuuunnnnssssiiiiggggnnnneeeedddd sssshhhhoooorrrrtttt from the
  159.      input stream and store it in ssss.
  160.  
  161.               virtual RWvistream&
  162.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(unsigned int& i);
  163.  
  164.  
  165.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next uuuunnnnssssiiiiggggnnnneeeedddd iiiinnnntttt from the
  166.      input stream and store it in iiii.
  167.  
  168.               virtual RWvistream&
  169.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(unsigned long& l);
  170.  
  171.  
  172.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnngggg from the
  173.      input stream and store it in llll.
  174.  
  175.               ooooppppeeeerrrraaaattttoooorrrr vvvvooooiiiidddd****();
  176.  
  177.  
  178.      Inherited via RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm from RRRRWWWWvvvviiiioooossss.
  179.  
  180. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  181.               virtual int
  182.           ggggeeeetttt();
  183.  
  184.  
  185.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get and return the next cccchhhhaaaarrrr from the
  186.      input stream.  Returns EEEEOOOOFFFF if end of file is encountered.
  187.  
  188.               virtual RWvistream&
  189.           ggggeeeetttt(char& c);
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next cccchhhhaaaarrrr and store it in cccc.
  207.  
  208.               virtual RWvistream&
  209.           ggggeeeetttt(wchar_t& wc);
  210.  
  211.  
  212.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next wide cccchhhhaaaarrrr and store it in
  213.      wwwwcccc.
  214.  
  215.               virtual RWvistream&
  216.           ggggeeeetttt(unsigned char& c);
  217.  
  218.  
  219.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next uuuunnnnssssiiiiggggnnnneeeedddd cccchhhhaaaarrrr and store it
  220.      in cccc.
  221.  
  222.               virtual RWvistream&
  223.           ggggeeeetttt(char* v, size_t N);
  224.  
  225.  
  226.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of cccchhhhaaaarrrrs and store them in
  227.      the array beginning at vvvv.  If the restore operation stops prematurely,
  228.      because there are no more data available on the stream, because an
  229.      exception is thrown, or for some other reason; ggggeeeetttt stores what has
  230.      already been retrieved from the stream into vvvv, and sets the failbit.
  231.  
  232.               virtual RWvistream&
  233.           ggggeeeetttt(wchar_t* v, size_t N);
  234.  
  235.  
  236.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of wide cccchhhhaaaarrrrs and store
  237.      them in the array beginning at vvvv. If the restore operation stops
  238.      prematurely, because there are no more data available on the stream,
  239.      because an exception is thrown, or for some other reason; ggggeeeetttt stores what
  240.      has already been retrieved from the stream into vvvv, and sets the failbit.
  241.  
  242.               virtual RWvistream&
  243.           ggggeeeetttt(double* v, size_t N);
  244.  
  245.  
  246.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of ddddoooouuuubbbblllleeees and store them
  247.      in the array beginning at vvvv.   If the restore operation stops
  248.      prematurely, because there are no more data available on the stream,
  249.      because an exception is thrown, or for some other reason; ggggeeeetttt stores what
  250.      has already been retrieved from the stream into vvvv, and sets the failbit.
  251.  
  252.               virtual RWvistream&
  253.           ggggeeeetttt(float* v, size_t N);
  254.  
  255.  
  256.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of ffffllllooooaaaatttts and store them
  257.      in the array beginning at vvvv.  If the restore operation stops prematurely,
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  269.  
  270.  
  271.  
  272.      because there are no more data available on the stream, because an
  273.      exception is thrown, or for some other reason; ggggeeeetttt stores what has
  274.      already been retrieved from the stream into vvvv, and sets the failbit.
  275.  
  276.               virtual RWvistream&
  277.           ggggeeeetttt(int* v, size_t N);
  278.  
  279.  
  280.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of iiiinnnntttts and store them in
  281.      the array beginning at vvvv.  If the restore operation stops prematurely,
  282.      because there are no more data available on the stream, because an
  283.      exception is thrown, or for some other reason; ggggeeeetttt stores what has
  284.      already been retrieved from the stream into vvvv, and sets the failbit.
  285.  
  286.               virtual RWvistream&
  287.           ggggeeeetttt(long* v, size_t N);
  288.  
  289.  
  290.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of lllloooonnnnggggs and store them in
  291.      the array beginning at vvvv.  If the restore operation stops prematurely,
  292.      because there are no more data available on the stream, because an
  293.      exception is thrown, or for some other reason; ggggeeeetttt stores what has
  294.      already been retrieved from the stream into vvvv, and sets the failbit.
  295.  
  296.               virtual RWvistream&
  297.           ggggeeeetttt(short* v, size_t N);
  298.  
  299.  
  300.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of sssshhhhoooorrrrtttts and store them
  301.      in the array beginning at vvvv.  If the restore operation stops prematurely,
  302.      because there are no more data available on the stream, because an
  303.      exception is thrown, or for some other reason; ggggeeeetttt stores what has
  304.      already been retrieved from the stream into vvvv, and sets the failbit.
  305.  
  306.               virtual RWvistream&
  307.           ggggeeeetttt(unsigned char* v, size_t N);
  308.  
  309.  
  310.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of uuuunnnnssssiiiiggggnnnneeeedddd cccchhhhaaaarrrrs and
  311.      store them in the array beginning at vvvv.   If the restore operation stops
  312.      prematurely, because there are no more data available on the stream,
  313.      because an exception is thrown, or for some other reason; ggggeeeetttt stores what
  314.      has already been retrieved from the stream into vvvv, and sets the failbit.
  315.  
  316.               virtual RWvistream&
  317.           ggggeeeetttt(unsigned short* v, size_t N);
  318.  
  319.  
  320.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of uuuunnnnssssiiiiggggnnnneeeedddd sssshhhhoooorrrrtttts and
  321.      store them in the array beginning at vvvv.  If the restore operation stops
  322.      prematurely, because there are no more data available on the stream,
  323.      because an exception is thrown, or for some other reason; ggggeeeetttt stores what
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  335.  
  336.  
  337.  
  338.      has already been retrieved from the stream into vvvv, and sets the failbit..
  339.  
  340.               virtual RWvistream&
  341.           ggggeeeetttt(unsigned int* v, size_t N);
  342.  
  343.  
  344.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of uuuunnnnssssiiiiggggnnnneeeedddd iiiinnnntttts and store
  345.      them in the array beginning at vvvv.   If the restore operation stops
  346.      prematurely, because there are no more data available on the stream,
  347.      because an exception is thrown, or for some other reason; ggggeeeetttt stores what
  348.      has already been retrieved from the stream into vvvv, and sets the failbit.
  349.  
  350.               virtual RWvistream&
  351.           ggggeeeetttt(unsigned long* v, size_t N);
  352.  
  353.  
  354.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnnggggs and
  355.      store them in the array beginning at vvvv.   If the restore operation stops
  356.      prematurely, because there are no more data available on the stream,
  357.      because an exception is thrown, or for some other reason; ggggeeeetttt stores what
  358.      has already been retrieved from the stream into vvvv, and sets the failbit.
  359.  
  360.               virtual RWvistream&
  361.           ggggeeeettttSSSSttttrrrriiiinnnngggg(char* s, size_t N);
  362.  
  363.  
  364.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Restores a character string from the
  365.      input stream and stores it in the array beginning at ssss.  The function
  366.      stops reading at the end of the string or after NNNN----1111 characters, whichever
  367.      comes first.  If NNNN----1111 characters have been read and the NNNNtttthhhh character is
  368.      not the string terminator, then the failbit of the stream will be set.
  369.      In either case, the string will be terminated with a null byte.
  370.  
  371.               virtual RWvistream&
  372.           ggggeeeettttSSSSttttrrrriiiinnnngggg(wchar_t* ws, size_t N);
  373.  
  374.  
  375.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Restores a wide character string from
  376.      the input stream and stores it in the array beginning at wwwwssss.  The
  377.      function stops reading at the end of the string or after NNNN----1111 characters,
  378.      whichever comes first. If NNNN----1111 characters have been read and the NNNNtttthhhh
  379.      character is not the string terminator, then the failbit of the stream
  380.      will be set.  In either case, the string will be terminated with a null
  381.      byte.
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.